import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;

import 'component.dart';
import 'state.dart';

Effect<SubjectTabState> buildEffect() {
  return combineEffects(<Object, Effect<SubjectTabState>>{
    Lifecycle.initState: _onInit,
  });
}

void _onInit(Action action, Context<SubjectTabState> ctx) async {
  if (ctx.state.tabController == null) {
    final TickerProvider tickerProvider =
        ctx.stfState as TickerSubjectComponentState;
    ctx.state.tabController =
        TabController(vsync: tickerProvider, length: ctx.state.tabs.length);
  }
}
